import Vue from 'vue'
import VueRouter from 'vue-router'

import DataPanel from "@/views/DataPanel.vue";
import PaperList from "@/views/PaperList.vue";
import ExamList from "@/views/ExamList.vue";

Vue.use(VueRouter)

const routes = [
    // 设置默认路由
    {
        path: '/',
        redirect: '/login'
    },
    {
      path: '/login',
    //   name: 'auth',
      component: () => import("@/views/AuthContainer.vue"),
      meta: {
        title: '账户',
        hideNavbar: true  // 添加标记，表示该路由下不显示导航栏
      },
      children: [
        {
          path: '',
          name: 'login',
          component: () => import("@/views/auth/Login.vue"),
          meta: {
            title: '登录',
            hideNavbar: true
          }
        },
        {
          path: 'register',
          name: 'register',
          component: () => import("@/views/auth/Register.vue"),
          meta: {
            title: '注册',
            hideNavbar: true
          }
        },
        {
          path: 'forgot-password',
          name: 'forgotPassword',
          component: () => import("@/views/auth/ForgotPassword.vue"),
          meta: {
            title: '找回密码',
            hideNavbar: true,
            hideInTabs: true  // 添加标记，表示在标签栏中不显示
          }
        }
      ]
    },
    {
        path: '/index',
        // name: 'IndexView',
        component: () => import("@/views/IndexView.vue"),
        meta: {
            title: '主页'
        },
        children: [
            // 设置默认路由
            {
                path: '/',
                redirect: '/question-bank'
            },
            {
                path: '/question-bank',
                // name: 'QuestionBank',
                component: DataPanel,
                meta: {
                    title: '题库管理',
                    type: 'question-bank'
                },
                children: [
                    // 设置默认路由
                    {
                        path: '/',
                        redirect: '/question-bank/bank-list'
                    },
                    {
                        path: '/question-bank/bank-list',
                        name: 'BankList',
                        component: () => import("@/components/questionbank/BankList.vue"),
                        meta: {
                            title: '题库列表'
                        }
                    },
                    {
                        path: '/question-bank/aiPanel-bank-result-header',
                        name: 'AiBankResultHeader',
                        component: () => import("@/components/questionbank/AIBankResultHeader.vue"),
                        meta: {
                            title: '智能题库生成'
                        }
                    }
                ]
            },
            {
                path: '/paper-index',
                // name: 'PaperIndex',
                component: () => import("@/views/PaperIndex.vue"),
                meta: {
                    title: '试卷主页',
                    type: 'paper'
                },
                children:[
                    // 设置默认路由
                    {
                        path: '/',
                        redirect: '/paper-index/paper-list'
                    },
                    {
                        path: '/paper-index/paper-list',
                        name: 'PaperList',
                        component: PaperList,
                        meta: {
                            title: '试卷列表'
                        }
                    },
                    {
                        path: '/paper-index/editor',
                        name: 'PaperEditorModal',
                        component:() => import("@/components/paper/PaperEditorModal.vue"),
                        meta: {
                            title: '编辑框'
                        }
                    },
                    {
                        path: '/paper-index/generator',
                        name: 'AipaperGeneratorResultHeader',
                        component: () => import("@/components/paper/AipaperGeneratorResultHeader.vue"),
                        meta: {
                            title: '生成框'
                        }
                    }
                
                ]
            },
            {
                path: '/exam-manage',
                name: 'ExamList',
                component: ExamList,
                meta: {
                    title: '考试列表'
                }
            },
            {
                path: "/student-management",
                name: "StudentManagement",
                component: () => import("@/views/StudentManagement.vue"),
                meta: {
                    title: "学生管理"
                }
            },
            {
                path: "/aiPanel-bank-result-header",
                redirect: "/question-bank/aiPanel-bank-result-header"
            },
            {
                path: "/aiPanel-paperGenerator",
                name: "AiPaperGenerator",
                component: () => import("@/components/paper/AipaperGeneratorResultHeader.vue"),
                meta: {
                    title: "智能试卷生成"
                }
            }
        ]
    },
    // 404页面
    {
        path: '/404',
        name: 'NotFound',
        component: () => import('@/views/ErrorPages/NotFound.vue'),
        meta: {
            title: '页面未找到',
            hideNavbar: true
        }
    },
    // 500页面
    {
        path: '/500',
        name: 'ServerError',
        component: () => import('@/views/ErrorPages/ServerError.vue'),
        meta: {
            title: '服务器错误',
            hideNavbar: true
        }
    },
    // 捕获所有未匹配的路由，重定向到404
    {
        path: '*',
        redirect: '/404'
    }
]

const router = new VueRouter({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
